#include "common.h"

#ifndef THREADCACHE_H
#define THREADCACHE_H



class ThreadCache
{
public:
	void* Allocate(size_t size);
	void Deallocate(void* ptr, size_t size);

	void* FetchFromCentralCache(size_t index, size_t size);
	void ListTooLong(FreeList& list, size_t size);
private:
	FreeList _freeLists[N_FREELIST];
};


#ifdef _WIN32 // windows
	static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;  // windows-TLS(thread local storage)
#else // linux
	static __thread ThreadCache* pTLSThreadCache = nullptr;  // linux-TLS
#endif

#endif // !THREADCACHE_H